package com.example.finaltool.controller;

import com.example.finaltool.model.Result;
import com.example.finaltool.service.SysCorpService;
import com.example.finaltool.service.ToolService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

/**
 * @author dengbw
 * @date 2021/8/23 3:48 下午
 */
@Api(tags = "2.系统工具", value = "system")
@RestController
@RequestMapping("system")
public class SystemController {

    SysCorpService sysCorpService;
    ToolService toolService;

    @Autowired
    public SystemController(SysCorpService sysCorpService,
                            ToolService toolService) {
        this.sysCorpService = sysCorpService;
        this.toolService = toolService;
    }

    @ApiOperation(value = "清除数据")
    @DeleteMapping("clean/{corpId}")
    public Result<Boolean> clean(@PathVariable("corpId") String corpId) {
        return toolService.clean(corpId);
    }

    @ApiOperation("区域id补全")
    @PutMapping("corp/area")
    @Transactional(rollbackFor = Exception.class)
    public Result<String> fillId() {
        return sysCorpService.fillId();
    }
}
